package com.eonmind.user.mapper;

import com.eonmind.common.contract.data.base.BaseMongoMapper;
import com.eonmind.common.contract.enums.DelEnum;
import com.eonmind.common.contract.enums.StatusEnum;
import com.eonmind.common.provider.entity.user.NotificationType;
import com.mongoplus.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Xujie
 * @since 2025/6/1 11:10
 **/

@Component
public class NotificationTypeMapper extends BaseMongoMapper<NotificationType> {
    public List<NotificationType> selectByIds(List<Long> noticeTypeIds) {
        if (ObjectUtils.isEmpty(noticeTypeIds)) {
            return List.of();
        }
        Set<Long> noticeTypeIdSet = new HashSet<>(noticeTypeIds);
        QueryWrapper<NotificationType> eq = createMgoQuery()
                .in(NotificationType::getId, noticeTypeIdSet)
                .eq(NotificationType::getStatus, StatusEnum.OPENED.getCode())
                .eq(NotificationType::getDel, DelEnum.UN_DEL.getCode());
        return list(eq);
    }


    public List<NotificationType> selectAllValid() {
        QueryWrapper<NotificationType> eq = createMgoQuery()
                .eq(NotificationType::getStatus, StatusEnum.OPENED.getCode())
                .eq(NotificationType::getDel, DelEnum.UN_DEL.getCode());
        return list(eq);
    }
}
